﻿#pragma once
#include<stdio.h>
#include<Windows.h>
#include<stdbool.h>
#include<stdlib.h>
#include<time.h>


#define pos_x 24
#define pos_y 5
#define wall L'◇'
#define body L'■'
#define foods L'★'


enum DIRECTION//蛇方向
{
	up=1,down,left,right
};
enum GAME_STATUS//蛇状态
{
	ok,
	kill_by_wall,
	kill_by_self,
	end
};
typedef struct SnakeNode//蛇身
{
	int x;
	int y;
	struct SnakeNode* next;
}SnakeNode,* pSnakeNode;

typedef struct Snake//蛇长
{
	pSnakeNode _pSnake;
	pSnakeNode pFood;
	enum DIRECTION dir;
	enum GAME_STATUS sta;
	int food_goal;
	int score;
	int sleep_time;
}Snake,*pSnake;


 void startGame(pSnake ps);//初始化
 void WelcomeToGame();//欢迎界面
 void CreatMap();//绘制地图
 void InitSnake(pSnake ps);//创建蛇
 void CreateFood(pSnake ps);//创建食物
 void runGame(pSnake ps);//运行游戏
 void SnakeMove(pSnake ps);//走一步
 int NextIsFood(pSnakeNode pNextNode, pSnake ps);//判断食物
 void EatFood(pSnakeNode pNextNode, pSnake ps);//吃掉
 void NoFood(pSnakeNode pNextNode, pSnake ps);//下一个不是食物
 void KillByWall(pSnake ps);//撞墙
 void KillBySelf(pSnake ps);//撞自己
 void endgame(pSnake ps);//善后
